﻿using ConsulTestClient.Helper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace ConsulTestClient.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class TestController : ControllerBase
    {
        private readonly ILogger<TestController> _logger;

        public TestController(ILogger<TestController> logger)
        {
            _logger = logger;
        }

        [HttpGet]
        public IActionResult Get()
        {
            //从Consul获取服务地址并请求：https://www.cnblogs.com/muchengqingxin/tag/consul/
            string realUri = ConsulService.Convert("http://127.0.0.1:8700", "dc1", "http://ConsulServer/info");

            string result = new HttpHelper().HttpGet(realUri);

            return Ok(result);
        }
    }
}
